﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Controls_TimKiem : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadSearchCategory();
        }
    }
    private void loadSearchCategory()
    {
        ChoDienTuDataContext cdt = new ChoDienTuDataContext();
        ddlCategory.DataSource = cdt.Select_AllCategory();
        ddlCategory.DataValueField = "ID";
        ddlCategory.DataTextField = "CategoryName";
        ddlCategory.DataBind();
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        String key = txtTuKhoa.Text;
        if (key == "Từ khóa tìm kiếm" || key == "")
            key = "?";
        int catid = int.Parse(ddlCategory.SelectedValue.ToString());
        Response.Redirect("Search.aspx?catid=" + catid + "&key=" + key);
    }
}
